<?php
//连接数据库
require_once 'config.php';

//接收id参数
$id = $_GET["id"];

//查询这条留言的内容
$sql = "SELECT * FROM `liuyan` WHERE `id` = $id";

$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // 输出单条留言内容
    $res = $result->fetch_assoc();
    $text = $res["text"];
} else {
    die("无此条留言");
    //die()后面的就不执行 ===跟exit()一样
}
?>

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>编辑留言</title>
</head>

<body style="border:1px solid black;padding:10px 10px;background-color: gainsboro;">
    <h1><?php echo $title; ?></h1>
    <hr/>
    <h3 style="color:blue;font-family:cursive;">编辑第<?php echo $id;?>楼的留言内容</h3>
    <form action="update.php" method="get">
        <input hidden type="text" name="id" value="<?php echo $id; ?>">
        <textarea name="text" cols="30" rows="10"><?php echo $text; ?></textarea>
        <p><input type="submit" value="更新留言"  style="cursor: pointer;"></p>
    </form>

    
</body>

</html>